# https://www.luogu.com.cn/problem/P3372
import sys


def inp() -> str:
    return sys.stdin.readline().strip("\n").strip("\r").strip(" ")


n, m = map(int, inp().split(" "))
a = list(map(int, inp().split(" ")))
t = [0] * ((n + 3) * 4)
lazy = [0] * ((n + 3) * 4)  # 懒标记


def build(rt: int = 1, l: int = 1, r: int = n) -> None:  # 递归建树
    if l == r:
        t[rt] = a[l - 1]
        return
    mid = (l + r) // 2
    build(rt * 2, l, mid)  # 左儿子位于rt*2的位置
    build(rt * 2 + 1, mid + 1, r)  # 右儿子在rt*2+1的位置，如果不理解，看https://oi-wiki.org/ds/seg/
    t[rt] = t[rt * 2] + t[rt * 2 + 1]


def add(L: int, R: int, k: int, rt: int = 1, l: int = 1, r: int = n) -> None:  # 区间加
    if L <= l and r <= R:
        t[rt] += k * (r - l + 1)
        lazy[rt] += k
        return
    mid = (l + r) // 2
    if lazy[rt] != 0:  # 下放懒标记
        t[rt * 2] += (mid - l + 1) * lazy[rt]
        t[rt * 2 + 1] += (r - mid) * lazy[rt]
        lazy[rt * 2] += lazy[rt]
        lazy[rt * 2 + 1] += lazy[rt]
        lazy[rt] = 0
    if L <= mid:
        add(L, R, k, rt * 2, l, mid)
    if R > mid:
        add(L, R, k, rt * 2 + 1, mid + 1, r)
    t[rt] = t[rt * 2] + t[rt * 2 + 1]


def query(L: int, R: int, rt: int = 1, l: int = 1, r: int = n) -> int:  # 区间求和，和上面相似
    if L <= l and r <= R:
        return t[rt]
    mid = (l + r) // 2
    if lazy[rt] != 0:  # 下放懒标记
        t[rt * 2] += (mid - l + 1) * lazy[rt]
        t[rt * 2 + 1] += (r - mid) * lazy[rt]
        lazy[rt * 2] += lazy[rt]
        lazy[rt * 2 + 1] += lazy[rt]
        lazy[rt] = 0
    ret = 0
    if L <= mid:
        ret += query(L, R, rt * 2, l, mid)
    if R > mid:
        ret += query(L, R, rt * 2 + 1, mid + 1, r)
    return ret


build()
for i in range(m):
    ask = list(map(int, inp().split(" ")))
    if ask[0] == 1:
        add(ask[1], ask[2], ask[3])
    else:
        print(query(ask[1], ask[2]))
